<?php
/**
 * 采购需求材料明细
 */
class DemandItems {
	const STATE_NULL	= 0; //初始状态
	const STATE_SUMMARY = 1; //汇总需求
	const STATE_QUOTE	= 2; //录入报价
	const STATE_INDENT	= 3; //进入采购
	const STATE_FAIL	= 9; //无法采购，见feedback字段说明

	static function add($data){
		return Db::get(__CLASS__)->insert($data)->exec();
	}

	static function getByDemand($demand_id){
		return Db::get(__CLASS__)->select()->where(array('demand_id'=>$demand_id))
				->order('sno ASC')->getAll();
	}

	static function deleteByDemand($demand_id){
		return Db::get(__CLASS__)->delete()->where(array('demand_id'=>$demand_id))->exec()
				&& Db::get(__CLASS__)->affectedRows() ? true : false;
	}

}
?>
